$(document).ready(function() {
	
$('input[fieldtype="DATE"]').datepicker();
$('input[fieldtype="DATE"]').datepicker( "option", "dateFormat", 'd M yy');

$('input[fieldtype="NTO1"]').each(function(){
	$(this).autocomplete({
		source: "/objects/nto1/" + $(this).attr('name') + "/", 
		minLength : 1
	});
});

function showRequest(formData, jqForm, options) 
{
	return true;
}
function showResponse(responseText, statusText, xhr, $form) 
{ 
	$('#AJAX_RESPONSE').attr('class', 'unhidden');
	ret = jQuery.parseJSON(responseText);
	$('#AJAX_RESPONSE').html(ret.rm);
	if(ret.rc == 0) {
		$('#USERFORM').clearForm();
	}
}

$('#USERFORM').ajaxForm({
	beforeSubmit:  showRequest, 
	success: showResponse
}); 


}); //document ready